package exo1;

public abstract class Compte {

	private String nom;
	private int numeroCompte;
	private double solde;
	private boolean ouvert;

	public Compte(String nom, int numeroCompte, double solde) {
		this.nom = nom;
		this.numeroCompte = numeroCompte;
		this.solde = solde;
		this.ouvert = true;
	}

	public double getSolde()
	{
		return this.solde;
	}

	public boolean setSolde(double Solde)
	{
		if (this.ouvert == true)
		{
			this.solde = solde;
			return true;
		} else
			return false;

	}

	public boolean getOuvert()
	{
		return this.ouvert;
	}

	public boolean setOuvert(boolean ouvert)
	{

		this.ouvert = ouvert;
		return true;

	}

	public boolean crediterCompte(double montant) throws MonException
	{
		if (this.ouvert == true)
		{

			this.solde = this.solde + montant;
			return true;
		} else
			throw new MonException("Operation impossible");
	}

	public boolean debiterCompte(double montant) throws MonException
	{
		if (this.ouvert == true)
		{

			this.solde = this.solde - montant;
			return true;
		} else
			throw new MonException("Operation impossible");
	}

}
